<?php

namespace Drupal\shusy_product_commission\ViewsController;

use Drupal\shusy_product_commission\ViewsController\handler\field\ShusyProductCommissionStandardAmount1ViewsField;
use Drupal\shusy_product_commission\ViewsController\handler\field\ShusyProductCommissionStandardAmount2ViewsField;
use Drupal\shusy_product_commission\ViewsController\handler\field\ShusyProductCommissionStandardAmountTypeViewsField;
use Drupal\shusy_product_commission\ViewsController\handler\field\ShusyProductCommissionStandardEditLinkViewsField;
use Drupal\shusy_product_commission\ViewsController\handler\field\ShusyProductCommissionStandardStatusViewsField;
use Drupal\shusy_product_commission\ViewsController\handler\filter\ShusyProductCommissionStandardAmountTypeViewsFilter;
use Drupal\shusy_product_commission\ViewsController\handler\filter\ShusyProductCommissionStandardStatusViewsFilter;
use EntityDefaultViewsController;


class ShusyProductCommissionStandardViewsController extends EntityDefaultViewsController {

  public function views_data() {
    $data = parent::views_data();
    if (!empty($this->info['base table'])) {
      $table = $this->info['base table'];
      $info = [];

      $info[$table]['edit_link'] = [
        'title' => t('编辑'),
        'help' => t('编辑.'),
        'field' => [
          'handler' => ShusyProductCommissionStandardEditLinkViewsField::class,
        ],
      ];
      $info[$table]['amount_type'] = [
        'title' => '返佣模式 0 跟随产品 1 固定金额 2 价格比例',
        'help' => '返佣模式 0 跟随产品 1 固定金额 2 价格比例',
        'real field' => 'amount_type',
        'field' => [
          'handler' => ShusyProductCommissionStandardAmountTypeViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyProductCommissionStandardAmountTypeViewsFilter::class,
        ],
      ];
      $info[$table]['amount_1'] = [
        'title' => '固定金额',
        'help' => '固定金额',
        'real field' => 'amount_1',
        'field' => [
          'handler' => ShusyProductCommissionStandardAmount1ViewsField::class,
        ],
      ];
      $info[$table]['amount_2'] = [
        'title' => '价格比例',
        'help' => '价格比例',
        'real field' => 'amount_2',
        'field' => [
          'handler' => ShusyProductCommissionStandardAmount2ViewsField::class,
        ],
      ];
      $info[$table]['status'] = [
        'title' => '状态 0 禁用 1 启用',
        'help' => '状态 0 禁用 1 启用',
        'real field' => 'status',
        'field' => [
          'handler' => ShusyProductCommissionStandardStatusViewsField::class,
        ],
        'filter' => [
          'handler' => ShusyProductCommissionStandardStatusViewsFilter::class,
        ],
      ];

      $data = drupal_array_merge_deep($data, $info);
    }
    return $data;
  }
}
